package com.ftx.controller.test.java8;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
 * Created by fengtingxin on 2020/4/26.
 *
 * java8集合特性
 */
public class CollectionNew {

    public static void main(String[] args) {

        System.out.println(  );

        List<String> names1 = new ArrayList<String>();
        names1.add("Google ");
        names1.add("Runoob ");
        names1.add("Taobao ");
        names1.add("Baidu ");
        names1.add("Sina ");

        CollectionNew collectionNew = new CollectionNew();
//        collectionNew.sortUsingJava8(names1);
        System.out.println(names1);

    }


    // 使用 java 7 排序
    private void sortUsingJava7(List<String> names){
        Collections.sort(names, new Comparator<String>() {
            @Override
            public int compare(String s1, String s2) {
                return s1.compareTo(s2);
            }
        });
    }


    //使用java 8排序

//    // 使用 java 8 排序
//    private void sortUsingJava8(List<String> names){
//        Collections.sort(names, (s1, s2) -> s1.compareTo(s2));
//    }
}
